#pragma once 

using namespace System;

namespace squirrel
{
	namespace record
	{
		public ref class ResultRow
		{
		private:
			int _Count;
			array<Object^>^ _Values;
			int _Status;

		public:
			ResultRow(int count)
			{
				if(count <= 0)
				{
					throw gcnew ArgumentException("count");
				}
				_Count = count;
				_Values = gcnew array<Object^>(count);
				_Status = 1;
			}

			ResultRow(array<Object^>^ values, int status)
			{
				_Count = values->Length;
				_Values = values;
				_Status = status;
			}

			Object^ GetValue(int field)
			{
				if(field < 0 || field >= _Count)
				{
					throw gcnew ArgumentOutOfRangeException("field");
				}
				return this->_Values[field];
			}

			void SetValue(int field, Object^ value)
			{
				if(field < 0 || field >= this->_Count)
				{
					throw gcnew ArgumentOutOfRangeException("field");
				}
				this->_Values[field] = value;
			}

			array<Object^>^ GetValues()
			{
				return this->_Values;
			}

			void SetValues(array<Object^>^ values)
			{
				if(values == nullptr) return;

				for(int i = 0; i < values->Length && i < this->_Count; i++)
				{
					this->_Values[i] = values[i];
				}
			}

			property int Status
			{
				int get()
				{
					return this->_Status;
				}
			}

			void SetStatus(int value)
			{
				this->_Status  = value;
			}
		};
	}
}